package String.s5;

import java.util.ArrayList;
import java.util.List;

public class test_345 {
    public static void main(String[] args) {
        Solution s = new Solution();

        System.out.println(s.reverseVowels("leetcode"));
    }
}
class Solution {
    public String reverseVowels(String s) {
        int len=s.length();
        int l=0,r=len-1;
        char[] arr = s.toCharArray();
        while(l<r){
            while(l<r&&!check(arr[l])){
                ++l;
            }
            while(l<r&&!check(arr[r])){
                --r;
            }
            if(l<r){
                swap(arr,l,r);
                ++l;
                --r;
            }
        }
        return new String(arr);
    }
    public void swap(char[] arr,int l,int r){
        char temp=arr[l];
        arr[l]=arr[r];
        arr[r]=temp;
    }
    public Boolean check(char c){
        return "aeiouAEIOU".indexOf(c)>=0;
    }
}
